package com.haois.ws.api.module.leavemsg.service;

import com.haois.ws.api.module.leavemsg.daomain.Message;
import com.haois.ws.api.module.leavemsg.dao.mapper.MsgMapper;
import com.haois.ws.common.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class MsgService {

    @Autowired
    private MsgMapper msgMapper;

    public void add(Message message) {
        message.setCreateTime(DateUtil.getYMdHms());
        msgMapper.addMsg(message);
    }


    public List<Message> getMsg() {
        List<Message> messages = msgMapper.getMsg();
        return messages;
    }

    public Message getById(Integer id) {
        Message message = msgMapper.getById(id);
        return message;

    }

    public void delete(Integer id) {
        msgMapper.delete(id);
    }

    public List<Message> getMsgByAppId(String appId) {
        List<Message> messages = msgMapper.getMsgByAppId(appId);
        return messages;
    }

}
